// 广告商管理相关API
import request from '@/utils/request'

// 获取所有广告商列表
const getAdsList = () => {
  return request({
    url: '/api/ads/getAllads',
    method: 'get',
  })
}

// 获取单个广告商详情
const getAdsDetail = (id) => {
  return request({
    url: `/api/ads/${id}`,
    method: 'get'
  })
}

// 创建广告商
const createAds = (data) => {
  return request({
    url: '/api/ads',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  })
}

// 更新广告商信息
const updateAds = (id, data) => {
  return request({
    url: `/api/ads/${id}`,
    method: 'put',
    data,
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  })
}

// 删除广告商
const deleteAds = (id) => {
  return request({
    url: `/api/ads/${id}`,
    method: 'delete'
  })
}

// 更新广告商状态
const updateAdsStatus = (id, status) => {
  return request({
    url: `/api/ads/${id}/status`,
    method: 'put',
    data: { status },
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  })
}

// 设置默认广告商
const setDefaultAds = (id) => {
  return request({
    url: `/api/ads/${id}/default`,
    method: 'put'
  })
}

export {
  getAdsList,
  getAdsDetail,
  createAds,
  updateAds,
  deleteAds,
  updateAdsStatus,
  setDefaultAds

}